<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_BACK?>
                            <?php echo XXF_LNAME?>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	<div style="font-weight: 900;margin:5px;">新公文发布：</div>
                        	<input type="text" id="ntitle" style="width:100%;margin-bottom:3px;" placeholder="标题" class="form-control" >
                            <textarea name="content" style="width:100%;height:200px;visibility:hidden;" id="todo" ></textarea>
                            <div style="border: 2px solid #bbb;padding:5px;margin-top:3px;">
                            	抄送:<br>
                            	<?php 
                            	foreach ($user as $v){
                            	?>
                            	<div style="background-color:#eee;width:65px;display:inline-block;">
                            		<input type="checkbox" name="checkbox" value="<?php echo $v['id']?>" id="u_<?php echo $v['id']?>">
                            		<label for="u_<?php echo $v['id']?>"><?php echo $v['realname']?></label>
                            	</div>
                            	<?php 
                            	}
                            	?>
                            </div>
                            <button class='btn btn-success'  style="margin-top: 3px;" onclick="add()"><span class='glyphicon glyphicon-plus' aria-hidden='true'>提交</span>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script charset="utf-8" src="kindeditor/kindeditor-all.js"></script>
    <script>
    var editor1;
	KindEditor.ready(function(K) {
		editor1 = K.create('textarea[name="content"]', {
			resizeType : 1,
			allowPreviewEmoticons : false,
			items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
                'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap'
            ]
		});
	});
	function add(){
		$ntitle=$("#ntitle").val();
		if($ntitle.length<1){
			$.xalert("标题不能为空！");
			return;
		}
		editor1.sync();
		$content=$("[name='content']").val();
		if($content.length<1){
			$.xalert("内容不能为空！");
			return;
		}
		$cb=$("[name='checkbox']:checked");
		if($cb.size()==0){
			$.xconfirm("没有选择抄送，是否继续？",function(tf){
				if(tf){
					action($ntitle,$content,$cb);
				}
			});
		}else{
			action($ntitle,$content,$cb);
		}
	}
	function action($ntitle,$content,$cb){
		$id="id";
		$cb.each(function(k,v){
			$id+="_"+v.value;
		});
		$.xpost("gongwen",{type:"addaction",ntitle:$ntitle,content:$content,ids:$id},function(data){
			$.xloading(0);
			if(data==1){
				$.xalert("操作成功！",function(){
					location.href="gongwen";
				});
			}else{
				$.xalert("操作失败！");
			}
		});
	}
	</script>